<ul class="block">
	<li>
		<div id="queryPortGroups_desc" class="description_div">
			<!-- append description -->
		</div>
	</li>
</ul>
<ul>
	<li>
		<div id="queryPortGroups_execution">
			<!-- append execution code -->
		</div>
	</li>
</ul>
<ul>
	<li>
		<div id="queryPortGroups_src" class="sourcecode_div">
			<!-- append source code -->
		</div>
	</li>
</ul>

<script type="text/javascript"><!--
	$(document).ready(function(){
		$.ajax({
			type : "get",
			cache : false,
			url : "pages/description/queryPortGroups_desc.html",
			async : false,
			success : function(data) {
				$("#queryPortGroups_desc").html(data);
			}
		});
		
		$.ajax({
			type : "get",
			cache : false,
			url : "pages/execution/queryPortGroups_execution.html",
			async : false,
			success : function(data) {
				$("#queryPortGroups_execution").html(data);
			}
		});
		
		$.ajax({
			type : "get",
			cache : false,
			url : "pages/sourcecode/queryPortGroups_src.html",
			async : false,
			success : function(data) {
				$("#queryPortGroups_src").html(data);
			}
		});
	});

	function queryPortGroupsCall()
	{
		// 清空信息
		$("#queryPortGroups_resultCode").val("");
		$("#PortGroupsInfo").html("");
		$("#queryPortGroupsReqEx_limitErrTip").html("");
		$("#queryPortGroupsReqEx_offsetErrTip").html("");
		$("#queryPortGroups_status").html("");
		$("#queryDVSwitchEx_uriErrTip").html("");
		
		var name = $("#queryPortGroupsReqEx_name").val();
		var limit = $("#queryPortGroupsReqEx_limit").val();
		var start = $("#queryPortGroupsReqEx_offset").val();
		var dVSwitch = $("#queryDVSwitchEx_uri").val();
		
		if(!checkPortGroups())
		{
			return false;		
		}
		
		$.ajax({
			url : "queryPortGroupsServlet",
			type : "post",
			dataType : "json",
			data : "dVSwithUri=" + dVSwitch + "&name=" + name + "&limit=" + limit +"&start=" + start +"&method=queryPortGroups",
			async : true,
			success : function(data)
			{
				$("#waittingDiv").css({"display":"none"});
				$("#waittingImgDiv").css({"display":"none"});
				
				if ("00000000" != data.errorCode)
				{
					$("#queryPortGroups_resultCode").val(data.errorCode);
					$("#queryPortGroups_status").html(controller.language.titles["operationFailed"]);
					$("#queryPortGroups_status").css({"color" : "red"});
				}
				else
				{
					$("#queryPortGroups_resultCode").val(data.errorCode);
					var portGroupsInfoStr = JSON.stringify(data.result);
					if (portGroupsInfoStr)
					{
						$("#PortGroupsInfo").val(showPortGroups(data.result));
					}
					$("#queryPortGroups_status").html(controller.language.titles["operationSuccess"]);
					$("#queryPortGroups_status").css({"color" : "blue"});
				}
				
			},
			error : function(data)
			{
				$("#waittingDiv").css({"display":"none"});
				$("#waittingImgDiv").css({"display":"none"});
				
				var res = data.responseText;
				$("#PortGroupsInfo").val("ajax Error");
				$("#queryPortGroups_status").html(controller.language.titles["operationFailed"]);
				$("#queryPortGroups_status").css({"color" : "red"});
			},
			beforeSend : function()
			{
				$("#queryPortGroups_resultCode").val("");
				$("#PortGroupsInfo").val("");
				$("#queryPortGroups_status").html("");
				
				$("#waittingDiv").css({"display":"block"});
				$("#waittingImgDiv").css({"display":"block"});
			}
		});
	}
	
	function checkPortGroups()
	{
		var correctFlag = true;
		var $focusObject = null;
		
		var $dVSwitchUri = $("#queryDVSwitchEx_uri");
		if (isEmpty($dVSwitchUri.val()))
		{
			$dVSwitchUri.css({"background-color":"#FBE9E5"});
			$("#queryDVSwitchEx_uriErrTip").html(controller.language.titles["queryDVSwitchEx_uriTip"]);
			correctFlag = false;
		}
		
		var $queryPortGroupsReqExOffset = $("#queryPortGroupsReqEx_offset");
		if (!isNumber($queryPortGroupsReqExOffset.val()) || parseInt($queryPortGroupsReqExOffset.val()) < 0)
		{
			$focusObject = $focusObject == null?$queryPortGroupsReqExOffset:$focusObject;
			$queryPortGroupsReqExOffset.css({"background-color":"#FBE9E5"});
			$("#queryPortGroupsReqEx_offsetErrTip").html(controller.language.titles["queryDataStores_offset_numRangeNull"]);
			correctFlag = false;
		}
		
		var $queryPortGroupsReqExLimit = $("#queryPortGroupsReqEx_limit");
		if (!isNumber($queryPortGroupsReqExLimit.val()) || parseInt($queryPortGroupsReqExLimit.val()) > 100 || parseInt($queryPortGroupsReqExLimit.val()) < 1)
		{
			$focusObject = $focusObject == null?$queryPortGroupsReqExLimit:$focusObject;
			$queryPortGroupsReqExLimit.css({"background-color":"#FBE9E5"});
			$("#queryPortGroupsReqEx_limitErrTip").html(controller.language.titles["queryDataStores_limit_numRangeNull"]);
			correctFlag = false;
		}
		
		if($focusObject) $focusObject.focus();
		return correctFlag;
	}
	
	function showPortGroups(portGroups)
	{
		var str = "Find " + portGroups.list.length + " data.portGroup(s).\n";
		for(var i = 0; i < portGroups.list.length; i++)
		{
			var portGroup = portGroups.list[i];
		    str += "portGroup " + (i+1) + " ----------------\n";
		    str += "arpBcstSuppress:" + portGroup.arpBcstSuppress + "\n";
		    str += "txBurstSize:" + portGroup.txBurstSize + "\n";
		    str += "name:" + portGroup.name + "\n";
		    str += "priority:" + portGroup.priority + "\n";
		    str += "description:" + portGroup.description + "\n";
		    str += "uri:" + portGroup.uri + "\n";
		    str += "\n";
		}
		return str;
	}
--></script>